package com.achao.controller;

import com.achao.beans.dto.Result;
import com.achao.beans.qo.QueryInfoQo;
import com.achao.service.MyMapService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: achao
 * @DateTime: 2022/10/18 0:57
 * @Description: TODO
 */

@RestController
@RequestMapping("/test")
public class TestMapController {

    @Value("${spring.datasource.username}")
    private String name;

    @Resource
    private MyMapService myMapService;

    @GetMapping("/hello")
    public String hello() {
        return name;
    }

    /**
     * 通过主键查询单个
     * @param id
     * @return
     */
    @GetMapping("/query/{id}")
    public Result query(@PathVariable Integer id) {
        return myMapService.queryById(id);
    }

    /**
     * 条件分页查询
     * @param queryInfoQo
     * @return
     */
    @PostMapping("/queryPage")
    public Result queryPag(@RequestBody QueryInfoQo queryInfoQo){
        return myMapService.queryPage(queryInfoQo);
    }

}
